﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using YXShop.Model.Order;

namespace YXShop.Web.controls
{
    public partial class floatingshopcart : System.Web.UI.Page
    {
        protected string ProductCount="0";
        protected string Url = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //添加数据
                int productid = ChangeHope.WebPage.PageRequest.GetInt("productId");
                int productCount = ChangeHope.WebPage.PageRequest.GetInt("q_proCount");
                if (productCount < 0)
                {
                    productCount = 1;
                }
                string productSpecification = ChangeHope.WebPage.PageRequest.GetString("q_proSpecification");
                string fittingsProductId = ChangeHope.WebPage.PageRequest.GetString("q_fittingsProId");
                string fittingsProductCount = ChangeHope.WebPage.PageRequest.GetString("q_fittingsProCount");
                int fittingsId = ChangeHope.WebPage.PageRequest.GetInt("q_proSpareparId");
                ProfileCommon Profile = new ProfileCommon();
                if (productid > 0)
                {
                    Profile.ShoppingCart.Add(productid.ToString(), productSpecification, productCount, fittingsProductId, fittingsProductCount, fittingsId);
                    HttpContext.Current.Profile.Save();
                }
                ICollection<CartItemInfo> cart = Profile.ShoppingCart.CartItems;
                ProductCount = cart.Count.ToString();
                string Url = YXShop.TemplateAction.Common.UrlStr("shoppingcart", "", "product/");
                this.Button3.Attributes.Add("onclick", "javascript:window.open('" + Url + "');");
            }
        }
    }
}
